<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :default-sort = "{prop: 'date', order: 'descending'}"
    >
      <el-table-column
        align="center"
        prop="orderTime"
        label="起始日期"
        sortable
        width="180">
      </el-table-column>
      <el-table-column
        align="center"
        prop="endTime"
        label="终止日期"
        width="180">
      </el-table-column>
      <el-table-column
        align="center"
        prop="userName"
        label="用户名"
        width="180">
      </el-table-column>
      <el-table-column
        align="center"
        prop="hospitalName"
        label="医院">
      </el-table-column>
      <el-table-column
        align="center"
        prop="wheelchairFuction"
        label="轮椅类型">
      </el-table-column>
      <el-table-column
        align="center"
        prop="phone"
        label="电话号码">
      </el-table-column>
      <el-table-column
        align="center"
        prop="price"
        label="租金">
      </el-table-column>
      <el-table-column
        align="center"
        prop="amount"
        label="费用">
      </el-table-column>
    </el-table>
    <pager :pageNo="searchParams.pageNo" :pageSize="searchParams.pageSize" :total=$store.state.backstage.orderIInfo.total :continues="5" @getPageNo="getPageNo"></pager>
  </div>
  </template>

<script>
import pager from "../pager";
export default {
  name:'RentalInformation',
  data() {
    return {
      searchParams:{
        pageNo:1,
        pageSize:3,
      },
      tableData: []
    }
  },
  components:{
    pager
  },
  mounted() {
    this.getData()
  },
  methods: {
    getPageNo(pageNo){
      this.searchParams.pageNo = pageNo
      //再次请求
      this.getData()
    },
    formatter(row, column) {
      return row.address;
    },
    //获取订单信息
    async getData(){
      await this.$store.dispatch('getOrders',{page:this.searchParams.pageNo,pageSize:this.searchParams.pageSize})
      this.showOrderInfo()
    },
    showOrderInfo(){
      this.tableData.splice(0,this.tableData.length)
      this.$store.state.backstage.orderIInfo.records.forEach((item)=>{
        let {orderTime,endTime,userName,wheelchairFuction,price,amount,hospitalName,phone} = item
        let order = {
          orderTime:orderTime,
          endTime:endTime,
          userName:userName,
          hospitalName:hospitalName,
          wheelchairFuction:wheelchairFuction,
          phone:phone,
          price:price,
          amount:amount
        }
        this.tableData.push(order)
      })
    }
  }
}
</script>
